<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>layout 后台大布局 - Layui</title>
  <link rel="stylesheet" href="/pro/layui/css/layui.css">
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
  <div class="layui-header">
    <div class="layui-logo">layui 后台布局</div>
    <!-- 头部区域（可配合layui已有的水平导航） -->
    <ul class="layui-nav layui-layout-right">
      <li class="layui-nav-item">
        <a href="javascript:;">
          <img src="http://t.cn/RCzsdCq" class="layui-nav-img">贤心
        </a>
        <dl class="layui-nav-child">
          <dd><a href="">基本资料</a></dd>
          <dd><a href="">安全设置</a></dd>
        </dl>
      </li>
      <li class="layui-nav-item"><a href="/pro/logout">退了</a></li>
    </ul>
  </div>
  
  <div class="layui-side layui-bg-black">
    <div class="layui-side-scroll">
      <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
      <ul class="layui-nav layui-nav-tree"  lay-filter="test">

      </ul>
    </div>
  </div>
  
  <div class="layui-body">
    <!-- 内容主体区域 -->
    <div style="padding: 15px;">内容主体区域</div>
  </div>
  
  <div class="layui-footer">
    <!-- 底部固定区域 -->
    © layui.com - 底部固定区域
  </div>
</div>
<script type="text/javascript" src="/pro/js/jquery-3.4.1.js"></script>
<script src="/pro/layui/layui.js"></script>
<script>
//JavaScript代码区域
<!--加载菜单-->
  		function loadMenu(){
  			$.ajax({
  			   type: "get",
  			   url: "/pro/showMenu",
  			   async: false,
  			   data:{id:${admin.id}},
  			   success: function(data){
  				   var $tree = $(".layui-nav-tree");
  				   $tree.html("");
  				   $(data).each(function(i,n){
  					   var temp = "<li class=\"layui-nav-item\">";
  					   temp += "<a class=\"\" href=\"javascript:;\">"+n.name+"</a>";
  					   temp += "<dl class=\"layui-nav-child\">";
  					   $(n.childs).each(function(i,n){
  						 temp += "<dd><a href=\"javascript:;\" onclick=\"$('.layui-body').load('/pro/"+n.url+"?id="+n.id+"')\" >"+n.name+"</a></dd>";
  					   })
  					   temp += "</dl></li>";
						$tree.append(temp);
  				   })
  			   }
  			});
  		}
  		layui.use(['element','form','layer'], function(){
  	        var element = layui.element;
  	        var form = layui.form;
  	      	var layer = layui.layer;
  	        loadMenu();
  	        element.render();
  	    });
</script>
  
</body>
</html>